//
//  CaSiViewController.m
//  NhomTuan
//
//  Created by Buffalo on 1/30/15.
//  Copyright (c) 2015 Buffalo. All rights reserved.
//

#import "CaSiViewController.h"

@interface CaSiViewController ()

@end

@implementation CaSiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}
- (void)viewWillAppear:(BOOL)animated {
    self.collectionCaSi.delegate = self;
    self.collectionCaSi.dataSource = self;
    [self.navigationController.navigationBar setBarTintColor:[AppUtils greenColor]];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    UIImage *image = [UIImage imageNamed:@"img_logo.png"];
    UIImageView *titleImg = [[UIImageView alloc] initWithImage:image];
    [self.navigationController.navigationBar.topItem setTitleView:titleImg];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    NSIndexPath *indexPath = [self.collectionCaSi indexPathsForSelectedItems][0];
    CaSiSongListViewController *caSiViewControl = (CaSiSongListViewController *)segue.destinationViewController;
    caSiViewControl.singer = [[Singer alloc] initSingerInArray:[AppManager defaultmanager].singerList atIndex:indexPath.row];
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    NSString *cellId = @"casi_collection_cell_id";
    CaSiCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
    Singer *singer = [[Singer alloc] initSingerInArray:[AppManager defaultmanager].singerList atIndex:indexPath.row];
    cell.imgCaSiAvatar.image = singer.avatar;
    cell.lblSingName.text = singer.name;
    return cell;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return [AppManager defaultmanager].singerList.count;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
